package com.jy.adscm.operation.mscyb.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.exception.AdscmSystemException;
import com.jy.adscm.operation.mscyb.bean.JqcsSettingDraws;
import com.jy.adscm.operation.mscyb.bean.JqdbSettingsDraws;
import com.jy.adscm.operation.mscyb.mapper.mysql.JqdbSettingsDrawsMapper;
import com.jy.adscm.operation.mscyb.service.JqdbSettingsDrawsService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.utils.AdscmBaseUtils;
import com.jy.adscm.zltx.bean.JyDrawingList;
import com.jy.adscm.zltx.bean.JyDrawingRole;
import com.jy.adscm.zltx.mapper.mysql.JyDrawingListMapper;
import com.jy.adscm.zltx.mapper.mysql.JyDrawingRoleMapper;
import com.jy.adscm.zltx.service.JyDrawingListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2019-06-17
 */
@Service
public class JqdbSettingsDrawsServiceImpl extends ServiceImpl<JqdbSettingsDrawsMapper, JqdbSettingsDraws> implements JqdbSettingsDrawsService {
@Autowired
    JyDrawingListService jyDrawingListService;
@Autowired
    JyDrawingRoleMapper jyDrawingRoleMapper;
@Autowired
JyDrawingListMapper jyDrawingListMapper;
    @Override
    public List<JqdbSettingsDraws> selectJqdbSettingsDrawssByPid(String pid) {
        Wrapper<JqdbSettingsDraws> wrapper =new EntityWrapper<>();
        wrapper.eq("pid",pid);
        List<JqdbSettingsDraws> jqdbSettingsDrawses = super.selectList(wrapper);
        for (JqdbSettingsDraws jqcsSettingsDraws : jqdbSettingsDrawses) {
            JyDrawingList jyDrawingList = jyDrawingListMapper.selectById(jqcsSettingsDraws.getCid());
            if (AdscmBaseUtils.getInstance().isNotEmpty(jyDrawingList,null)){
                jqcsSettingsDraws.setCidName(jyDrawingList.getDrawingName());
            }
        }
        return jqdbSettingsDrawses;
    }

    @Override
    public List<JyDrawingList> selectAll(Integer parentId,Integer id ) throws AdscmSystemException {
        Wrapper<JyDrawingList> wrapper=new EntityWrapper<>();
        wrapper.eq("parent_id",parentId);
        wrapper.eq("drawing_type",id);
        List<JyDrawingList> jyDrawingLists = jyDrawingListMapper.selectList(wrapper);
        return jyDrawingLists;
    }
}
